package com.sun.controller;/**
 * @author sun
 * @date 2021/12/29 - 16:34
 */

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @description: 登录controller
 * @author 孙
 * @date 2021/12/29 16:34
 * @version 1.0
 */
@Controller
public class LoginController {

    @RequestMapping("/tomain")
    /*@Secured("ROLE_abc") 权限给错，会报500的错误*/
    /*@PreAuthorize("hasRole('abc')")允许ROLE_开头 权限给错，会报500的错误*/
    @PreAuthorize("hasRole('abc')")
    public String main(){
        System.out.println("执行main登录方法");
        return "redirect:main.html";
    }
    @RequestMapping("/toerror")
    public String error(){
        System.out.println("执行error登录方法");
        return "redirect:error.html";
    }

    @RequestMapping("/demo")
    public String demo(){
        return "demo";
    }
    @RequestMapping("showLogin")
    public String showLogin(){
        return "login";
    }

/*
    @RequestMapping("/demo.html")
    public String login(){
        System.out.println("执行登录方法");
        return "demo.html";
    }
*/


}
